package com.lge.clock.util;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.hardware.LGSensor;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.StatFs;
import android.os.SystemProperties;
import android.provider.MediaStore;
import android.telephony.TelephonyManager;
import android.text.format.DateFormat;
import android.util.Log;

import com.lge.clock.alarmclock.Alarms;
import com.lge.clock.timer.Timers;
import com.lge.clock.util.MediaInfoHolder.MediaLocation;
import com.lge.provider.SettingsEx;
/* LGSI_CHANGE_E :Arab/Farsi Number conversion*/
/**
 * @author minjoong.park
 */
public class CommonUtil {
    private static final String TAG = "CommonUtil";
    
	private static final String M24_CHECK = "kk:mm";
	private static final String M12_CHECK = "h:mm";
	
	public static final int ONE_SEC_WITH_MILLI = 1000;
	public static final int SECONDS_IN_A_MINUTE = 60;
	public static final int STR_BUF_DEF_SIZE = 16;
	
	/*[START] 2011.10.06 suein1209.kim @blocking the 3D map enter and leave button cuz out of memory*/
	/**
	 * Block the jittering the 3D map enter button
	 */
	public static final ExecutorService ENTER_EXECUTOR = Executors.newSingleThreadExecutor();
	/**
	 * Block the jittering the 3D map leave button
	 */
	public static final ExecutorService LEAVE_EXECUTOR = Executors.newSingleThreadExecutor();
	/**
	 * Block the enter button 
	 */
	public static boolean MAP_ENTER_FLAG = true;
	/**
	 * Block the leave button
	 */
	public static boolean MAP_LEAVE_FLAG = true;
	/**
	 * Blocking jitter button delay time(millisecond) 
	 */
	public static int MAP_DELAY_ENTER_TIME = 600;
	/*[END] 2011.10.06 suein1209.kim @blocking the 3D map enter and leave button cuz out of memory*/
	
	public static boolean STOP_DIALOG_REDUNDANCY = true;

	private static String mModelName = "";
	
	public final static String ANDY_FLEX_PACKAGE_PATH = "com.lge.provider.Andy_Flex";
	
	public final static String KEY_SYSTEM_PROPERTIES_OPERATOR_CODE = "ro.build.target_country";
	public final static String KEY_SYSTEM_PROPERTIES_COUNTRY_CODE = "ro.build.target_operator";
	
	public final static String SYSTEM_PROPERTIES_VZW_OPERATOR_CODE = "VZW";
	public final static String SYSTEM_PROPERTIES_VZW_COUNTRY_CODE = "US";
	
	public final static String FLEX_VZW_OPERATOR_CODE = "VZW";
	public final static String FLEX_VZW_COUNTRY_CODE ="US";
	
	public final static String SYSTEM_PROPERTIES_SKT_OPERATOR_CODE = "SKT"; 
	public final static String FLEX_SKT_OPERATOR_CODE = "SKT";
	
	public final static String SYSTEM_PROPERTIES_KT_OPERATOR_CODE = "KT"; 
    public final static String FLEX_KT_OPERATOR_CODE = "KT";
    
    public final static String SYSTEM_PROPERTIES_LGU_OPERATOR_CODE = "LGU"; 
    public final static String FLEX_LGU_OPERATOR_CODE = "LGU";
    
    public final static String KOREA_COUNTRY_CODE = "KR";
    
    private static boolean mGestureGuideisChecked=false;
    
	
	public static String getDateFormat(final Context context) {
		String strResult = M12_CHECK;
		
		if ( DateFormat.is24HourFormat(context) ) 
			strResult = M24_CHECK;
		
		return strResult;
	}
	
	//[hyunjung78.park][1406] 2011.10.12  START
    public static boolean isLowOnSpaceMemory(Context context) {
    	
    	final String strDATA_PATH = "/data";
    	
        StatFs mDataFileStats = new StatFs(strDATA_PATH);
        mDataFileStats.restat(strDATA_PATH);
        
        long mFreeMem = (long) mDataFileStats.getAvailableBlocks() * mDataFileStats.getBlockSize();
        long memThreshold = 1048576L; // 1MB
        Log.v(TAG, " mFreeMem = "+Long.toString(mFreeMem)+", memThreshold = "+Long.toString(memThreshold));  
        
        if (mFreeMem < memThreshold) {
            return true;
        } else {
            return false;
        }
	}
    //[hyunjung78.park][1406] 2011.10.12 END	
	/**
     * Method getModelName.
     * @return mModelName String
     * @author minjoong.park@lge.com
     */
    public static String getModelName(){
        mModelName = Build.MODEL; 
            return mModelName;
    }
    
    /**
     * Method isVZW 
     * @return boolean
     * @author minjoong.park@lge.com
     */
    public static boolean isVZW() {
        boolean mCheck = false;     
        String mModelName = CommonUtil.getModelName().trim();
        String mModelInitial = null;
        for(int i = 0; i < mModelName.length();i++){
            String mm = mModelName.substring(i, i+1);
            if(mm.equals("-")){
                mCheck = true;
            }
        }
        if(mCheck){
            String[] mModelSplitModelName = mModelName.split("-");
            String mModel = mModelSplitModelName[1];
            mModelInitial = mModel.substring(0, 1);
        }else{
            mModelInitial = mModelName.substring(0, 1);
        }
        Log.d(TAG, "mModelInitial => " + mModelInitial);
        
        if(mModelInitial.equals("V")){
            return true;
        }
        
        return false;
    }
    
    /**
     * Method setPouchAlert
     * @return void
     * @author minjoong.park@lge.com
     */
//    public static void setPouchAlert(AlertDialog dialog){
//        try {
//            Class<?> c = Class.forName("android.app.AlertDialog");
//            Method m = c.getMethod("setResAlert", int.class);
//            
//            Class<?> d = Class.forName("com.android.internal.R.layout");
//            Field field = d.getField("alert_dialog_pouch_shutdown");
//            m.invoke(dialog, field.getInt(null));
//            
//        } catch (ClassNotFoundException e) {
//            //e.printStackTrace();
//            Log.d(TAG, "ClassNotFoundException");
//        } catch (SecurityException e) {
//            //e.printStackTrace();
//            Log.d(TAG, "SecurityException");
//        } catch (NoSuchMethodException e) {
//            //e.printStackTrace();
//            Log.d(TAG, "NoSuchMethodException");
//        } catch (IllegalArgumentException e) {
//            //e.printStackTrace();
//            Log.d(TAG, "IllegalArgumentException");
//        } catch (IllegalAccessException e) {
//            //e.printStackTrace();
//            Log.d(TAG, "IllegalAccessException");
//        } catch (InvocationTargetException e) {
//            //e.printStackTrace();
//            Log.d(TAG, "InvocationTargetException");
//        } catch (NoSuchFieldException e) {
//            //e.printStackTrace();
//            Log.d(TAG, "NoSuchFieldException");
//        }
//    }

    /* LGSI_CHANGE_S :Arab/Farsi Number conversion
     * 2012-02-15, sarah.ganihar@lge.com,
     * To Convert numbers to Arab/Farsi numerals.
     */
     public static  boolean isArabFarsiLanguage() {
        String currentLanguage = Locale.getDefault().getLanguage();

        if (currentLanguage.equalsIgnoreCase("ar") || currentLanguage.equalsIgnoreCase("fa"))
        {
            return true;
        }
        else
        {
            return false;
        }
     }
     
     public static boolean isHebrewLanguage(){
         String currentLanguage = Locale.getDefault().getLanguage();

         if (currentLanguage.equalsIgnoreCase("iw")){
             return true;
         }else{
             return false;
         }
     }

      public static String convertArabFarsiNum(String ActualStr,boolean Trim) {
          int check = 0;
          char[] arabfarsi_str = new char[ActualStr.length()];

          if (Locale.getDefault().getLanguage().equalsIgnoreCase("ar"))
          {
              for (int i = 0; i < ActualStr.length(); i++) {
                  check = Character.digit(ActualStr.charAt(i), 10);
                  if (check >= 0 && check <= 9)
                      arabfarsi_str[i] = new Character((char) (check + 1632));
                  else
                      arabfarsi_str[i] = new Character(ActualStr.charAt(i));
              }
          }
          else if (Locale.getDefault().getLanguage().equalsIgnoreCase("fa")) {
              for (int i = 0; i < ActualStr.length(); i++) {
                  check = Character.digit(ActualStr.charAt(i), 10);
                      if (check >= 0 && check <= 9)
                          arabfarsi_str[i] = new Character((char) (check + 1776));
                      else
                          arabfarsi_str[i] = new Character(ActualStr.charAt(i));
               }
          }
          String ArabFarsi_Str = new String(arabfarsi_str);
          if(Trim)
              return ArabFarsi_Str;
          else
              return ArabFarsi_Str.trim();
    }
 /* LGSI_CHANGE_E :Arab/Farsi Number conversion */


    /**
     * 2012.03.16 suein1209.kim
     * get default ring tone in DB
     * @param context
     * @return
     */
	private static MediaInfoHolder getDefaultRingTone(Context context) {
		Cursor cur = null;
		try {
			cur = context.getContentResolver().query(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, INTERNAL_COLUMNS, "is_alarm = 1",  null, "_id");
			if (cur != null && cur.moveToFirst()){
				MediaInfoHolder retMIF = new MediaInfoHolder();
				retMIF.mediaTitle = cur.getString(1);
				retMIF.mediaURI = ContentUris.withAppendedId(Uri.parse(cur.getString(2)),cur.getLong(0));
				retMIF.mediaIdNum = cur.getLong(0);
				retMIF.dateModifiedValue = cur.getLong(4);
				retMIF.fileSizeValue = cur.getLong(5);
				
				return retMIF;
			} //End Of if (cu != null && cu.moveToFirst()){
			
		} catch (Exception e) {
			Log.e(TAG, "Exception : CommonUtil -> getDefaultRingTone : "+e.getMessage());
		} finally {
			if (cur != null)cur.close();
		} //End Of try
		
		return null;
		
	} // End Of Method getDefaultRingTone
	
    /**
     * 2012.01.31 suein1209.kim
	 * get Default Ring Tone URI
     * @param mActivity
     * @param is Alarm
     * @return
     */
	public static MediaInfoHolder getDefaultRingToneInfo(Context mContext, AlarmDBQueryCondition aDBCondition){
		
		MediaInfoHolder retMIF =getOperatorDefaultMediaInfo(mContext.getContentResolver());
		
		if(retMIF.mediaLocation == MediaLocation.NO_WHERE){
			//if not exist
			/*ring tone URI = null*/
			retMIF = getDefaultRingTone(mContext);
			if(retMIF == null){
				Uri ringToneUri = RingtoneManager.getActualDefaultRingtoneUri(mContext, RingtoneManager.TYPE_ALARM);
				if (ringToneUri != null){
					retMIF = getMediaInfo(mContext.getContentResolver(), ringToneUri.toString(), aDBCondition);
				}else{
					retMIF = new MediaInfoHolder();
				} //End Of if
			} //End Of if
		} //End Of if
		
		return retMIF;
	} //End Of Method getDefaultRingToneURI
	
	/**
	 * 2012.01.31 suein1209.kim
	 * 
	 * get Media file location 
	 * 
	 * @param ringToneURI
	 * @param is Alarm
	 * @return
	 */
	public static MediaInfoHolder getMediaInfo(ContentResolver mResolver, Uri ringToneURI, AlarmDBQueryCondition aDBCondition){
		return ringToneURI != null ? getMediaInfo(mResolver, ringToneURI.toString(), aDBCondition) : getMediaInfo(mResolver, "", aDBCondition); 
	} //End Of Method getMediaInfo
	
	/**
	 * 2012.01.31 suein1209.kim
	 * Media store DB internal columns
	 */
	private static final String[] INTERNAL_COLUMNS = new String[] {
		android.provider.BaseColumns._ID, 
		android.provider.MediaStore.MediaColumns.TITLE,
		"\"" + MediaStore.Audio.Media.INTERNAL_CONTENT_URI + "\"",
		android.provider.MediaStore.Audio.AudioColumns.TITLE_KEY,
		android.provider.MediaStore.Audio.AudioColumns.DATE_MODIFIED,
		android.provider.MediaStore.MediaColumns.SIZE
	};
	
	/**
	 * 2012.01.31 suein1209.kim
	 * Media store DB external columns
	 */
	private static final String[] EXTERNAL_COLUMNS = new String[] {
	    android.provider.BaseColumns._ID,
		android.provider.MediaStore.MediaColumns.TITLE,
		"\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"",
		android.provider.MediaStore.Audio.AudioColumns.TITLE_KEY,
		android.provider.MediaStore.Audio.AudioColumns.DATE_MODIFIED,
		android.provider.MediaStore.MediaColumns.SIZE
	};
	
	/**
	 * 2012.01.31 suein1209.kim
	 * 
	 * get Media file location 
	 * 
	 * @param ringToneURI
	 * @param mResolver
	 * @param is Alarm
	 * @return
	 */
	public static MediaInfoHolder getMediaInfo(ContentResolver mResolver, String ringToneURI, AlarmDBQueryCondition aDBCondition){
		
		if(ringToneURI == null){
			return new MediaInfoHolder();
			
		}else if(ringToneURI.equalsIgnoreCase("Off")){
			return new MediaInfoHolder();
			
		}else if(ringToneURI.equalsIgnoreCase("On")){
			return new MediaInfoHolder();
			
		}else if(ringToneURI.length() < 1){
			return new MediaInfoHolder();
			
		} //End Of if
		
		MediaInfoHolder retMIF = null;
		String []token = ringToneURI.split("/");
		String idNum3er = token[token.length-1];
		
		ringToneURI = ringToneURI.trim();
		if (ringToneURI.indexOf("content://media/external") >= 0){
			/*is External path ? */
			retMIF = getMediaInfoInStoreDB(mResolver, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, EXTERNAL_COLUMNS, idNum3er, "_id", aDBCondition);
			if(retMIF != null){
				retMIF.mediaLocation = MediaLocation.EXTERNAL_SDCARD;
			} //End Of if
			
		}else{
			/*is Internal path ? */
			retMIF = getMediaInfoInStoreDB(mResolver, MediaStore.Audio.Media.INTERNAL_CONTENT_URI, INTERNAL_COLUMNS, idNum3er, MediaStore.Audio.Media.DEFAULT_SORT_ORDER, aDBCondition);
			if(retMIF != null){
				retMIF.mediaLocation = MediaLocation.INTERNAL_MEMORY;
			} //End Of if
			
		} //End Of if
		
		return retMIF == null ? new MediaInfoHolder() : retMIF; 
	} //End Of Method getMediaLocation
	
	/**
	 * 2012.01.31 suein1209.kim
	 * Media information holder
	 * @param mResolver
	 * @param contentUri
	 * @param colums
	 * @param mediaId
	 * @param sort
	 * @return
	 */
	private static MediaInfoHolder getMediaInfoInStoreDB(ContentResolver mResolver, Uri contentUri, String[] colums, String mediaId, String sort, AlarmDBQueryCondition aDBCondition){
		Cursor cur = null;
		try {
			
			String predic = aDBCondition == AlarmDBQueryCondition.NO_CONDITION ? "" : aDBCondition.value + " AND "; 
			cur = mResolver.query(contentUri, colums, predic+"_id = "+mediaId,  null, sort);
			if (cur != null && cur.moveToFirst()){
				MediaInfoHolder retMIF = new MediaInfoHolder();
				retMIF.mediaTitle = cur.getString(1);
				retMIF.mediaURI = ContentUris.withAppendedId(Uri.parse(cur.getString(2)),cur.getLong(0));
				retMIF.mediaIdNum = cur.getLong(0);
				retMIF.dateModifiedValue = cur.getLong(4);
				retMIF.fileSizeValue = cur.getLong(5);
				return retMIF;
			} //End Of if (cu != null && cu.moveToFirst()){
			
		} catch (Exception e) {
			Log.e(TAG, "Exception : TimerFragment -> isMediaExistInStoreDB : "+e.getMessage());
		} finally {
			if (cur != null)cur.close();
		} //End Of try
		
		return null;
	} //End Of Method getMediaInfoInStoreDB
	
	/**
	 * 2012.01.31 suein1209.kim
	 * 
	 * get Media file location 
	 * 
	 * @param mResolver
	 * @param is Alarm
	 * @return
	 */
	public static MediaInfoHolder getMediaInfo(ContentResolver mResolver, MediaDBCondition mdbc, AlarmDBQueryCondition aDBCondition){
		
		if(mdbc == null || aDBCondition == null || mResolver == null){
			return new MediaInfoHolder();
		} //End Of if
		
		
		MediaInfoHolder retMIF = null;
		try {
			/*is External path ? */
			retMIF = getMediaInfoInStoreDB(mResolver, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, EXTERNAL_COLUMNS, mdbc, "_id", aDBCondition);
		
			if(retMIF != null){
				retMIF.mediaLocation = MediaLocation.EXTERNAL_SDCARD;
				
				/*finish this methode*/
				return retMIF;
			} //End Of if
			
			retMIF = getMediaInfoInStoreDB(mResolver, MediaStore.Audio.Media.INTERNAL_CONTENT_URI, INTERNAL_COLUMNS, mdbc, MediaStore.Audio.Media.DEFAULT_SORT_ORDER, aDBCondition);
			if(retMIF != null){
				retMIF.mediaLocation = MediaLocation.INTERNAL_MEMORY;
				
				/*finish this methode*/
				return retMIF;
			} //End Of if
		} catch (Exception e) {
			Log.e(TAG, "Exception : "+e.getMessage());
		} //End Of try
		
		return retMIF == null ? new MediaInfoHolder() : retMIF; 
	} //End Of Method getMediaLocation
	
	/**
	 * 
	 * @param mResolver
	 * @param contentUri
	 * @param colums
	 * @param mediaId
	 * @param sort
	 * @param aDBCondition
	 * @return
	 */
	public static MediaInfoHolder getMediaInfoInStoreDB(ContentResolver mResolver, Uri contentUri, String[] colums, MediaDBCondition mdbc, String sort, AlarmDBQueryCondition aDBCondition) throws Exception{
		Cursor cur = null;
		try {
			
			String predic = aDBCondition == AlarmDBQueryCondition.NO_CONDITION ? "" : aDBCondition.value + " AND ";
			String mediaCondition = getMediaCondition(mdbc);
			
			if(mediaCondition.equals("")){
				throw new Exception("Empty MediaDBCondition Error");
			} //End Of if
				
			cur = mResolver.query(contentUri, colums, predic+mediaCondition,  null, sort);
			if (cur != null && cur.moveToFirst()){
				
				MediaInfoHolder retMIF = new MediaInfoHolder();
				retMIF.mediaTitle = cur.getString(1);
				retMIF.mediaURI = ContentUris.withAppendedId(Uri.parse(cur.getString(2)),cur.getLong(0));
				retMIF.mediaIdNum = cur.getLong(0);
				retMIF.dateModifiedValue = cur.getLong(4);
				retMIF.fileSizeValue = cur.getLong(5);
				return retMIF;
			} //End Of if (cu != null && cu.moveToFirst()){
			
		} catch (Exception e) {
			Log.e(TAG, "Exception : CommonUtil -> getMediaInfoInStoreDB : "+e.getMessage());
		} finally {
			if (cur != null)cur.close();
		} //End Of try
		
		return null;
	} //End Of Method MediaInfoHolder
	
	/**
	 * get Media Condition(will set)
	 * @return
	 */
	private static String getMediaCondition(MediaDBCondition mdbc){
		String ret = "";
		
		if (mdbc.isDateModifiedFlag()) {
			/*direct address*/
			ret = "date_modified = "+mdbc.getDateModifiedValue();
		} //End Of if
		
		if (mdbc.isFileSizeFlag()) {
			/*music file size*/
			ret = mdbc.isDateModifiedFlag() == true ? ret + " AND " : ret;
			
			ret += "_size = "+String.valueOf(mdbc.getFileSizeValue()).trim();
		} //End Of if
		
		if (mdbc.isTonePathNameFlag()) {
			ret = mdbc.isDateModifiedFlag() || mdbc.isFileSizeFlag() ? ret + " AND " : ret;
			
			// WBT #353421
			if (mdbc.getTonePathName() != null)
				ret += "_data = " + mdbc.getTonePathName().trim();
		} //End Of if
		
		return ret;
	} //End Of Method getMediaCondition
	
    /**
     * 2012.03.15 suein1209.kim
     * @author suein1209.kim
     */
    public enum PrefreParent {
    	ALARM(Alarms.RINGTONE_CONTAIN_ALARM),
    	TIMER(Timers.RINGTONE_CONTAIN_TIMER);
    	
    	PrefreParent(String value) {
    		this.value = value;
    	}

    	private final String value;
    	public String value() {
    		return value;
    	}
    } //End Of enum BuildMode
	
	/**
	 * get Fineded Default RingTone
	 * @return MediaInfoHolder
	 */
	public static MediaInfoHolder getFinededDefaultTone(Context context, String ringToneURI, AlarmDBQueryCondition aDBCondition, PrefreParent pp){
		MediaInfoHolder infoHolder = getMediaInfo(context.getContentResolver(), ringToneURI, aDBCondition); 
		MediaInfoHolder retHolder = infoHolder;
		if(infoHolder.mediaLocation == MediaLocation.NO_WHERE){

			SharedPreferences mSharedPreferences = context.getSharedPreferences(pp.value, 0);
			String ringtoneBackupV = mSharedPreferences.getString(ringToneURI.trim(), null);
			
			if(ringtoneBackupV != null){
				
				String[] valueToken = ringtoneBackupV.split(";");
				MediaDBCondition mdbc = new MediaDBCondition();
				mdbc.setFileSizeFlag(true);
				mdbc.setDateModifiedFlag(true);
				mdbc.setFileSizeValue(Integer.parseInt(valueToken[0]));
				mdbc.setDateModifiedValue(Integer.parseInt(valueToken[1]));
				MediaInfoHolder mdifh2ND = getMediaInfo(context.getContentResolver(), mdbc, aDBCondition);
				/*set return value*/
				retHolder = mdifh2ND;
				
			} //End Of if
			
		}else{
			
			/*set shared preference value*/
			setBackupToneInfoValue(context, infoHolder, pp);
		} //End Of if
		
		return retHolder;
	} //End Of Method getFinededDefaultTone
	
    /**
     * 2012.03.15 suein1209.kim
     * @author suein1209.kim
     */
    public enum AlarmDBQueryCondition {
    	NO_CONDITION(""),
    	SET_ALARM("is_alarm = 1"),
    	SET_MUSIC("is_music = 1");

    	AlarmDBQueryCondition(String value) {
    		this.value = value;
    	}

    	private final String value;
    	public String value() {
    		return value;
    	}
    } //End Of enum BuildMode

    /**
     * 2012.03.28 suein1209.kim
     * @return
     */
    public static MediaInfoHolder getOperatorDefaultMediaInfo(ContentResolver mResolver){
    	String tonePathName = "\""+"/system/media/audio/alarms/"+SystemProperties.get("ro.config.alarm_alert")+"\"";
    	
    	MediaDBCondition mdbc = new MediaDBCondition();
    	mdbc.setTonePathNameFlag(true);
    	mdbc.setTonePathName(tonePathName.trim());
    	
    	return getMediaInfo(mResolver, mdbc, AlarmDBQueryCondition.SET_ALARM);
    } //End Of Method getOperatorDefaultMediaInfo
    
    /**
     * 2012.01.27 suein1209.kim
     * is facing sensor supported ?
     * @return
     */
    public static boolean isFacingSensorSupported(Context context){
    	
    	SensorManager sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);    
    	// get all sensors of all types         
    	List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL); 
    	
    	for(int i=0; i<sensorList.size(); i++){
    		
    		if(sensorList.get(i).getType()== LGSensor.TYPE_SENSOR_LGE_GESTURE_FACING){
    			return true;
    		} //End Of if
    	} //End Of for i
    	
    	return false;
    } //End Of Method 

	// Operator
    public enum OPERATOR {
        /*reference  http://dev.lge.com/wiki/cappuccino/android_ca/target_code*/
        DGR,  //  2 Degree_jaiveer.jaswal_Contacts_sync
        ABM,  //  ALBANIA MOBILE COMM
        AHN,  //  AH Mobiel
        ASD,  //  ASDA
        ATT,  //  AT&T
        BAS,  //  BASE
        BELL,  //     Bell Mobility
        BEN,  //  BELCOMPANY
        BHT,  //  BH TELEKOM
        BIT,  //  BITE
        BM,   // Boost Mobile (Sprint MVNO - SPG)
        BYT,  //  BOUYGUES
        CAF,  //  CARREFOUR
        CAL,  //  CALL_ME
        CAN,  //  AUCHAN
        CBB,  //  CBB_Mobil
        CHS,  //  CHESS
        CLR,  //  Claro
        CMCC,  //     China Mobile Communications Corporation
        CMF,  //  COSMOFONE
        CSM,  //  COSMOTE
        CWH,  //  CARPHONE WAREHOUSE
        DBT,  //  DEBITEL
        DCM,  //  NTT Docomo
        DGF,  //  DIGICEL
        DLG,  //  DLG_TELE
        DLX,  //  DATALUX
        DNA,  //  DNA
        ELS,  //  ELISA
        EMT,  //  EMT
        EPL,  //  E-PLUS
        ERA,  //  ERA
        ERO,  //  ERONET
        ESK,  //  EUSKALTEL
        GGD,  //  GADU GADU
        GLB,  //  GLOBUL
        H3G,  //  Hutchison 3G
        HBP,  //  HALEBOP
        HYH,  //  HEYAH
        IDS,  //  IBERBANDA
        KPN,  //  KPN
        KT,   //   KT
        LGU,  //  LG U+
        LMT,  //  LMT
        LUG,  //  LUXGSM
        MBK,  //  MOBILKOM
        MDT,  //  MOLDTELECOM
        MET,  //  METEOR
        MOD,  //  MOBISUD
        MOV,  // Movistar
        MPCS,  //     Metro PCS
        MSV,  //  MOBITEL
        MTS,  //  M:TS
        MXUSC, // Mexico Lusacell
        NET,  //  NETCOM
        NRJ,  //  NRJ
        O2,   //   O2
        ONT,  //  OMNITEL
        OPEN,  //     All carriers in a region
        OPM,  //  OPTIMUS
        OPT,  //  Optus
        ORG,  //  Orange
        OUT,  //  OUTREMER TELECOM
        P4P,  //  P4
        PCL,  //  PCL
        PLS,  //  PLUS
        PNN,  //  PANNON
        PRO,  //  PROMONTE
        PSN,  // 
        PXN,  //  PROXIMUS
        RAB,  //  RABOMOBIEL
        RGS,  //  Rogers
        SFR,  //  SFR
        SIM,  //  SI_MOBILE
        SKT,  //  SK Telecom
        SLI,  //  SAUNALAHTI
        SMN,  //  SIMINN
        SON,  //  SONERA
        SPR,  //  Sprint
        SRR,  //  SRR
        SUK,  //  SAINSBURY
        SWC,  //  SWISSCOM
        TAN,  //  TANGO
        TCL,  //  Telcel
        TDC,  //  TDC
        TFT,  //  TELFORT
        TIM,  //  Telecom Italia Mobile
        TKM,  //  TALKMOBILE
        TL2,  //  TELE2
        TLA,  //  TELIA
        TLF,  //  Telefonica
        TLS,  //  Telus
        TMN,  //  TMN
        TMO,  //  T-Mobile, DTAG
        TMR,  //  TELMORE
        TNR,  //  TELENOR
        TRA,  //  Tellering
        TRF,  //  Tracfone
        TSC,  //  TESCO MOBILE
        TUS,  //  TUSMOBILE
        VDF,  //  Vodafone
        VIP,  //  VIP
        VIV,  //  Vivo
        VVC,  //  VIVACOM
        VZW,  //  Verizon Wireless
        WIN,  //  WIND
        YGS,  //  YOIGO
        
        
        // Not correct
        ENTLEL,  //  Chile Entel
        ETECSA,  //  Cuba ETECSA(Cubacel)
        SMOV,  // Unified Latin America(Venezuela) SSV Movistar
        
        TEL, 	// Telstra
        TMUS,	// T-Mobile USA
        KDDI,   // KDDI
        USC,    // USCellular USA
        UNF,    // UNF
        EOTMN,  // EOTMN
        
    	//TODO: add item, when you need        
    };
    
    
    
	// Country
    public enum COUNTRY {
        /*reference http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2*/
        AD,  //  Andorra   
        AE,  //  United Arab Emirates  
        AF,  //  Afghanistan  
        AG,  //  Antigua and Barbuda   
        AI,  //  Anguilla    
        AL,  //  Albania 
        AM,  //  Armenia 
        AO,  //  Angola   
        AQ,  //  Antarctica  
        AR,  //  Argentina   
        AS,  //  American Samoa   
        AT,  //  Austria 
        AU,  //  Australia   
        AW,  //  Aruba  
        AX,  //  Åland Islands 
        AZ,  //  Azerbaijan  
        BA,  //  Bosnia and Herzegovina 
        BB,  //  Barbados    
        BD,  //  Bangladesh  
        BE,  //  Belgium  
        BF,  //  Burkina Faso  
        BG,  //  Bulgaria   
        BH,  //  Bahrain 
        BI,  //  Burundi  
        BJ,  //  Benin 
        BL,  //  Saint Barthélemy   
        BM,  //  Bermuda 
        BN,  //  Brunei Darussalam   
        BO,  //  Bolivia, Plurinational State of 
        BQ,  //  Bonaire, Sint Eustatius and Saba    
        BR,  //  Brazil  
        BS,  //  Bahamas  
        BT,  //  Bhutan  
        BV,  //  Bouvet Island   
        BW,  //  Botswana   
        BY,  //  Belarus 
        BZ,  //  Belize  
        CA,  //  Canada  
        CC,  //  Cocos (Keeling) Islands 
        CD,  //  Congo, the Democratic Republic of the   
        CF,  //  Central African Republic   
        CG,  //  Congo  
        CH,  //  Switzerland 
        CI,  //  Côte d'Ivoire  
        CK,  //  Cook Islands     
        CL,  //  Chile   
        CM,  //  Cameroon   
        CN,  //  China   
        CO,  //  Colombia 
        CR,  //  Costa Rica   
        CU,  //  Cuba   
        CV,  //  Cape Verde  
        CW,  //  Curaçao 
        CX,  //  Christmas Island   
        CY,  //  Cyprus  
        CZ,  //  Czech Republic
        DE,  //  Germany
        DJ,  //  Djibouti   
        DK,  //  Denmark   
        DM,  //  Dominica   
        DO,  //  Dominican Republic 
        DZ,  //  Algeria 
        EC,  //  Ecuador  
        EE,  //  Estonia 
        EG,  //  Egypt   
        EH,  //  Western Sahara  
        ER,  //  Eritrea
        ES,  //  Spain  
        ET,  //  Ethiopia    
        FI,  //  Finland  
        FJ,  //  Fiji      
        FK,  //  Falkland Islands (Malvinas) 
        FM,  //  Micronesia, Federated States of 
        FO,  //  Faroe Islands   
        FR,  //  France 
        GA,  //  Gabon   
        GB,  //  United Kingdom 
        GD,  //  Grenada  
        GE,  //  Georgia 
        GF,  //  French Guiana   
        GG,  //  Guernsey   
        GH,  //  Ghana  
        GI,  //  Gibraltar 
        GL,  //  Greenland   
        GM,  //  Gambia   
        GN,  //  Guinea  
        GP,  //  Guadeloupe 
        GQ,  //  Equatorial Guinea  
        GR,  //  Greece  
        GS,  //  South Georgia and the South Sandwich Islands  
        GT,  //  Guatemala   
        GU,  //  Guam    
        GW,  //  Guinea-Bissau  
        GY,  //  Guyana    
        HK,  //  Hong Kong    
        HM,  //  Heard Island and McDonald Islands  
        HN,  //  Honduras  
        HR,  //  Croatia 
        HT,  //  Haiti     
        HU,  //  Hungary 
        ID,  //  Indonesia 
        IE,  //  Ireland  
        IL,  //  Israel   
        IM,  //  Isle of Man 
        IN,  //  India   
        IO,  //  British Indian Ocean Territory  
        IQ,  //  Iraq    
        IR,  //  Iran, Islamic Republic of   
        IS,  //  Iceland 
        IT,  //  Italy  
        JE,  //  Jersey  
        JM,  //  Jamaica  
        JO,  //  Jordan   
        JP,  //  Japan   
        KE,  //  Kenya  
        KG,  //  Kyrgyzstan  
        KH,  //  Cambodia  
        KI,  //  Kiribati   
        KM,  //  Comoros
        KN,  //  Saint Kitts and Nevis  
        KP,  //  Korea, Democratic People's Republic of (common name: North Korea)
        KR,  //  Korea, Republic of (common name: South Korea)
        KW,  //  Kuwait 
        KY,  //  Cayman Islands   
        KZ,  //  Kazakhstan 
        LA,  //  Lao People's Democratic Republic  
        LB,  //  Lebanon 
        LC,  //  Saint Lucia   
        LI,  //  Liechtenstein   
        LK,  //  Sri Lanka   
        LR,  //  Liberia   
        LS,  //  Lesotho  
        LT,  //  Lithuania  
        LU,  //  Luxembourg 
        LV,  //  Latvia 
        LY,  //  Libya   
        MA,  //  Morocco
        MC,  //  Monaco    
        MD,  //  Moldova, Republic of    
        ME,  //  Montenegro 
        MF,  //  Saint Martin (French part) 
        MG,  //  Madagascar   
        MH,  //  Marshall Islands   
        MK,  //  Macedonia, the former Yugoslav Republic of  
        ML,  //  Mali   
        MM,  //  Myanmar
        MN,  //  Mongolia    
        MO,  //  Macao   
        MP,  //  Northern Mariana Islands  
        MQ,  //  Martinique  
        MR,  //  Mauritania  
        MS,  //  Montserrat   
        MT,  //  Malta   
        MU,  //  Mauritius   
        MV,  //  Maldives      
        MW,  //  Malawi    
        MX,  //  Mexico  
        MY,  //  Malaysia    
        MZ,  //  Mozambique    
        NA,  //  Namibia
        NC,  //  New Caledonia    
        NE,  //  Niger  
        NF,  //  Norfolk Island    
        NG,  //  Nigeria   
        NI,  //  Nicaragua   
        NL,  //  Netherlands  
        NO,  //  Norway   
        NP,  //  Nepal    
        NR,  //  Nauru  
        NU,  //  Niue   
        NZ,  //  New Zealand 
        OM,  //  Oman   
        PA,  //  Panama  
        PE,  //  Peru   
        PF,  //  French Polynesia  
        PG,  //  Papua New Guinea     
        PH,  //  Philippines   
        PK,  //  Pakistan      
        PL,  //  Poland 
        PM,  //  Saint Pierre and Miquelon   
        PN,  //  Pitcairn  
        PR,  //  Puerto Rico   
        PS,  //  Palestinian Territory, Occupied 
        PT,  //  Portugal    
        PW,  //  Palau  
        PY,  //  Paraguay    
        QA,  //  Qatar   
        RE,  //  Réunion  
        RO,  //  Romania 
        RS,  //  Serbia 
        RU,  //  Russian Federation 
        RW,  //  Rwanda  
        SA,  //  Saudi Arabia    
        SB,  //  Solomon Islands 
        SC,  //  Seychelles
        SD,  //  Sudan  
        SE,  //  Sweden  
        SG,  //  Singapore  
        SH,  //  Saint Helena, Ascension and Tristan da Cunha 
        SI,  //  Slovenia   
        SJ,  //  Svalbard and Jan Mayen  
        SK,  //  Slovakia    
        SL,  //  Sierra Leone    
        SM,  //  San Marino   
        SN,  //  Senegal
        SO,  //  Somalia   
        SR,  //  Suriname    
        SS,  //  South Sudan   
        ST,  //  Sao Tome and Principe  
        SV,  //  El Salvador 
        SX,  //  Sint Maarten (Dutch part)  
        SY,  //  Syrian Arab Republic    
        SZ,  //  Swaziland  
        TC,  //  Turks and Caicos Islands      
        TD,  //  Chad    
        TF,  //  French Southern Territories 
        TG,  //  Togo     
        TH,  //  Thailand    
        TJ,  //  Tajikistan   
        TK,  //  Tokelau 
        TL,  //  Timor-Leste
        TM,  //  Turkmenistan       
        TN,  //  Tunisia 
        TO,  //  Tonga      
        TR,  //  Turkey     
        TT,  //  Trinidad and Tobago    
        TV,  //  Tuvalu     
        TW,  //  Taiwan, Province of China   
        TZ,  //  Tanzania, United Republic of  
        UA,  //  Ukraine
        UG,  //  Uganda  
        UM,  //  United States Minor Outlying Islands    
        US,  //  United States   
        UY,  //  Uruguay 
        UZ,  //  Uzbekistan 
        VA,  //  Holy See (Vatican City State)  
        VC,  //  Saint Vincent and the Grenadines     
        VE,  //  Venezuela, Bolivarian Republic of   
        VG,  //  Virgin Islands, British
        VI,  //  Virgin Islands, U.S. 
        VN,  //  Viet Nam  
        VU,  //  Vanuatu 
        WF,  //  Wallis and Futuna    
        WS,  //  Samoa   
        YE,  //  Yemen
        YT,  //  Mayotte 
        ZA,  //  South Africa
        ZM,  //  Zambia 
        ZW,  //  Zimbabwe
        
        COM,
        EU,     // Europe
        CIS,    // Commonwealth of Independent States

      //TODO: add item, when you need
    }; 	
    
    public static OPERATOR getBuildOperator() {
        String code = SystemProperties.get("ro.build.target_operator");        
        OPERATOR operator = OPERATOR.OPEN;
        try {
        	operator = OPERATOR.valueOf(code);
        } catch( IllegalArgumentException e ) {
        	Log.e(TAG, "unknown operator code="+code);
        }
        
        if( operator.equals(OPERATOR.TMO) && getBuildCountry().equals(COUNTRY.US) )
        	operator = OPERATOR.TMUS;

		if( operator.equals(OPERATOR.USC) && getBuildCountry().equals(COUNTRY.MX) )
			operator = OPERATOR.MXUSC;
		
        Log.i(TAG, "BUILD Operator: "+operator);
        
        return operator;
    } 
    
    public static COUNTRY getBuildCountry() {
        String code = SystemProperties.get("ro.build.target_country");
        COUNTRY country = COUNTRY.COM;
        try {
        	country = COUNTRY.valueOf(code);
        } catch( IllegalArgumentException e ) {
        	Log.e(TAG, "unknown country code="+code);
        }
        
        Log.i(TAG, "BUILD Country: "+country);
        
        return country;
    }
    
    /**
     * suein1209.kim
     * chekc is Sprint Operator
     * @return
     */
    public static boolean isSprintOperator(){
    	OPERATOR operator = getBuildOperator();
    	boolean ret = false;
    	if(operator == OPERATOR.BM || operator == OPERATOR.SPR){
    		ret = true;
    	} //End Of if
    	return ret;
    } //End Of Method isSprintOperator
    
//    /**
//     * 2012.03.09 suein1209.kim
//     * @author suein1209.kim
//     */
//    public enum BuildMode {
//    	NO_SEARCH("N/A"),
//    	L_DOCOMO("DS1106"), 
//    	D1L_U_PLUS("F160L"),
//    	M4("E610");
//
//    	BuildMode(String value) {
//    		this.value = value;
//    	}
//
//    	private final String value;
//    	public String value() {
//    		return value;
//    	}
//    } //End Of enum BuildMode
//	
//    /**
//     * 2012.03.09 suein1209.kim
//     * searching this model
//     * @return
//     */
//    public static BuildMode getBuildModel(){
//    	BuildMode ret = BuildMode.NO_SEARCH;
//    	if(Build.MODEL == null) return ret;
//    	
//    	if(Build.MODEL.indexOf(BuildMode.L_DOCOMO.value) >= 0){
//    		ret = BuildMode.L_DOCOMO;
//    		
//    	}else if(Build.MODEL.indexOf(BuildMode.M4.value) >= 0 ){
//    		ret = BuildMode.M4;
//    		
//    	}else if(Build.MODEL.indexOf(BuildMode.D1L_U_PLUS.value) >= 0){
//    		ret = BuildMode.D1L_U_PLUS;
//    		
//    	} //End Of if
//    	
//    	return ret;
//    } //End Of Method getBuildModel
    
    /**
     * is Asia language
     * (Korea, China, Japan, Taiwan)
     * @return
     */
    public static boolean isAsiaLanguage(Context context){

    	boolean bResult = false;
    	String language = context.getResources().getConfiguration().locale.getCountry();
    	if("KR".equalsIgnoreCase(language) ||
    		"CN".equalsIgnoreCase(language) ||
    		"JP".equalsIgnoreCase(language) ||
    		"TW".equalsIgnoreCase(language) ||
    		"HU".equalsIgnoreCase(language)){
    		bResult = true;
    	}
    	return bResult;
    } //End of Method isAsia
    
    /**
     * 2012.03.23 suein1209
     * @param mediaInfo
     */
	public static void setBackupToneInfoValue(Context mContext, MediaInfoHolder mediaInfo, PrefreParent pp) {
		
		/*exception*/
		if(mediaInfo.mediaURI == null) return;
		
		SharedPreferences prefs = mContext.getSharedPreferences(pp.value, 0);
		SharedPreferences.Editor ed = prefs.edit();
		ed.putString(mediaInfo.mediaURI.toString().trim(), mediaInfo.fileSizeValue +";"+mediaInfo.dateModifiedValue);
		ed.commit();
	} //End Of Method setBackupToneInfoValue
    
    public static void setGestureGuideChecked(boolean check){
    	mGestureGuideisChecked = check;
    }
    
    public static boolean getGestureGuideChecked(){
    	return mGestureGuideisChecked;
    }
    
    public static  String formatTotalTime( long time )
	{
		int iHour = 0;
		int iMin = 0;
		int iSec = 0;

		long sec = time;
		iHour = (int)( sec / 60 / 60 );
		iMin = (int)( ( sec / 60 ) % 60 );
		iSec = (int)( sec % 60 );

		return String.format( "%02d:%02d:%02d", iHour, iMin, iSec );
	}
    
    /**
     * 2012.04.04 suein1209.kim
     * Check call state(USIM1 and USIM2)
     * @return
     */
    public static boolean isCallStateIdle(TelephonyManager mTelephonyManager, Context mContext){
    	boolean ret = false;
    	
    	CallStateHolder csHolder = getNowCallState(mContext, mTelephonyManager);
    	final int CALL_STATE_IDLE = 0;
    	
    	if(isDualSimModel()){
    		if(csHolder.sim1State != CALL_STATE_IDLE || csHolder.sim2State != CALL_STATE_IDLE){
    			ret = false;
    		}else{
    			ret = true;
    		} //End Of Method if
    	}else{
    		if(csHolder.sim1State != CALL_STATE_IDLE){
    			ret = false;
    		}else{
    			ret = true;
    		} //End Of Method if
    	} //End Of if
    	
    	return ret;
    } //End Of Methode isCallStateIdle 
    
    /**
     * 2012.04.05 suein1209.kim
     * check is multi sim enabled in MSimManager 
     * @return
     */
    private static boolean isMultiSimEnabledInMSIMMgr(){
    	
    	boolean ret = false;
    	
		try {
			/* check is dual sim model */
			Class<?> mTelephonyManager = Class.forName("android.telephony.TelephonyManager");
			Method mGetDefault = mTelephonyManager.getMethod("getDefault", null);
			Object m2TelephonyManager = mGetDefault.invoke(mTelephonyManager, null);

			Method mIsMultiSimEnabled = m2TelephonyManager.getClass().getMethod("isMultiSimEnabled", null);
			ret = (Boolean) mIsMultiSimEnabled.invoke(m2TelephonyManager, null);
			
			Log.d(TAG, "isCallStateIdleInMultiSIM : " + ret);
			
		} catch (ClassNotFoundException e) {
			Log.e(TAG, "ClassNotFoundException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
			ret = false;
		} catch (SecurityException e) {
			Log.e(TAG, "SecurityException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
			ret = false;
		} catch (NoSuchMethodException e) {
			Log.e(TAG, "NoSuchMethodException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
			ret = false;
		} catch (IllegalArgumentException e) {
			Log.e(TAG, "IllegalArgumentException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
			ret = false;
		} catch (IllegalAccessException e) {
			Log.e(TAG, "IllegalAccessException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
			ret = false;
		} catch (InvocationTargetException e) {
			Log.e(TAG, "InvocationTargetException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
			ret = false;
		} //End Of try-Catch
		
		return ret;
    } //End Of Method isMultiSimEnabledInMSIMMgr
    
    /**
     * 2012.04.05 suein1209.kim
     * check is dual sim model
     * @return
     */
    private static boolean isDualSimModel(){
    	return Build.MODEL.indexOf("E615F") > 0 ? true : false;
    } //End Of Method isDualSimModel
    
    /**
     * 2012.04.05 suein1209.kim
     * get call state
     * @return
     */
    public static CallStateHolder getNowCallState(Context mContext, TelephonyManager mTelephonyManager){
    	
    	CallStateHolder retHolder = new CallStateHolder();
    	
    	if(isDualSimModel() && isMultiSimEnabledInMSIMMgr()){
    		/* ======= dual sim model ======*/
    		
    		/*Exception*/
    		if(mContext == null) return retHolder;
    		
    		try {
    			/* check be call state idle */
    			final int SIM_1 = 0; //SIM 1
    			final int SIM_2 = 1; //SIM 2
    			
    			Class<?> mMSimTelephonyManager = Class.forName("android.telephony.MSimTelephonyManager");
    			Object MSimTelephonyMgr2 = mMSimTelephonyManager.cast((Object) mContext.getSystemService("phone_msim"));
    			Method getCallState = MSimTelephonyMgr2.getClass().getMethod("getCallState", int.class);
    			
    			int sim1CallState = (Integer) getCallState.invoke(MSimTelephonyMgr2, SIM_1);
    			int sim2CallState = (Integer) getCallState.invoke(MSimTelephonyMgr2, SIM_2);
    			
    			Log.d(TAG, "isCallStateIdleInMultiSIM SIM1 State : " + sim1CallState);
    			Log.d(TAG, "isCallStateIdleInMultiSIM SIM2 State : " + sim2CallState);
    			
    			retHolder.sim1State = sim1CallState;
    			retHolder.sim2State = sim2CallState;
    			
    		} catch (ClassNotFoundException e) {
    			Log.e(TAG, "ClassNotFoundException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
    		} catch (SecurityException e) {
    			Log.e(TAG, "SecurityException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
    		} catch (NoSuchMethodException e) {
    			Log.e(TAG, "NoSuchMethodException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
    		} catch (IllegalArgumentException e) {
    			Log.e(TAG, "IllegalArgumentException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
    		} catch (IllegalAccessException e) {
    			Log.e(TAG, "IllegalAccessException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
    		} catch (InvocationTargetException e) {
    			Log.e(TAG, "InvocationTargetException => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
    		} catch (Exception e) {
    			Log.e(TAG, "Exception => CommomUtil => isCallStateIdleInMultiSIM : "+e.getMessage());
			} //End Of try-Catch
    		
    	}else{
    		/* ======= single sim model ======*/
    		retHolder.sim1State = mTelephonyManager.getCallState();
    		
    	} //End Of if
    	
    	return retHolder;
    } //End Of Method getNowCallState
    
    /**
     * Call State Holder
     * (Sim1 and Sim2 call state )
     * @author suein1209.kim
     */
    public static class CallStateHolder{
    	
    	/**
    	 * SIM 1 call state
    	 * IDLE = 0, RINGING =1, OFFHOOK =2, default = -1;
    	 */
    	public int sim1State = -1;
    	
    	/**
    	 * SIM 1 call state
    	 * IDLE = 0, RINGING =1, OFFHOOK =2, default = -1;
    	 */
    	public int sim2State = -1;
    	
    	public boolean equals(CallStateHolder csHolder) {
    		boolean ret;
    		
			/*dual sim model*/
			if(csHolder.sim1State != this.sim1State || csHolder.sim2State != this.sim2State){
				ret = false;
				
			}else{ 
				ret = true;
				
			}//End Of if
    		
    		return ret;
    	} //End Of Method
    	
    } //End Of class
    
    
    /**
     * Is use volume control for each indivisual alarm.
     * 
     * @return true (if use volume control)
     */
    public static boolean isUseVolumeControl(){   
    	
    	if(getBuildOperator() == OPERATOR.VZW)
    		return true;
    		
    	return false;
    }
    
    /**
     * Is DB version 2.0 ?
     * 
     * @return true(version 2.0), false(version 1.0)
     */
    public static boolean isUseDB2(){
    	if(isUseVolumeControl())
    		return true;
    	
    	return false;
    }
    
    /**
     * 2012.04.30
     * check Power LED setting info
     */
    public static int isPowerLEDSetInSettings(ContentResolver cr){
    	return SettingsEx.System.getInt(cr, "front_key_alarm", 0);
    } //End Of Method isPowerLEDSetInSettings
}
